﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace Brain.Photon
{
    /// <summary>
    /// Used to draw Particle Systems
    /// </summary>
    public class PhotonRenderer : IDrawable
    {
        /// <summary>
        /// The Particle Emitter you are drawing
        /// </summary>
        public ParticleEmitter ParticleEmitter { get; protected set; }

        public bool ShouldDraw { get; set; }

        /// <summary>
        /// If this Renderer can update the Particles instead of the Particle System.
        /// </summary>
        public bool CanHandleParticleUpdate { get; protected set; }

        /// <summary>
        /// If this Renderer is a GPU Renderer.
        /// </summary>
        public bool IsGPURenderer { get; protected set; }

        /// <summary>
        /// If this (CPU) Renderer needs the Particles to calculate their World Transforms
        /// </summary>
        public bool CPU_NeedsTransform = false;

        private bool shouldHandleParticleUpdate = false;
        /// <summary>
        /// If this Renderer should handle the Particles Update instead of the Particle System.
        /// Be aware that if the CanHandleParticleUpdate is false this Property won't set to true.
        /// </summary>
        public bool ShouldHandleParticleUpdate
        {
            get { return shouldHandleParticleUpdate; }
            set
            {
                if (value)
                {
                    if (CanHandleParticleUpdate)
                    {
                        shouldHandleParticleUpdate = value;
                    }
                    else
                    {
                        shouldHandleParticleUpdate = false;
                    }
                }
                else
                {
                    shouldHandleParticleUpdate = value;
                }
            }
        }

        /// <summary>
        /// Instantiates a new PhotonRenderer
        /// </summary>
        /// <param name="particleSystem">The Particle System you are drawing</param>
        protected PhotonRenderer(ParticleEmitter particleEmitter)
        {
            this.ParticleEmitter = particleEmitter;

            particleEmitter.AssignRenderer(this);

            ShouldDraw = true;
        }

        /// <summary>
        /// Draw the Photon Renderer
        /// </summary>
        public virtual void Draw()
        {

        }

        public virtual float GetParticleTime(Particle p)
        {
            throw new NotImplementedException();
        }
        public virtual Vector3 GetParticleCurrentPosition(Particle p)
        {
            throw new NotImplementedException();
        }
    }
}
